<?php // seleccionarBd.phtml ?>
<?php if (count($this->baseDeDatos) < 1): ?>
    <i> No existe ninguna base de datos, proceda a importar  </i>
    <a href="/admin/access/importar">alguna</a>
<?php else: ?>
    <h3>Lista de configuraciones</h3>
    <form action="/admin/configuracion/seleccionar/" method="POST">
        <table id="lista-configuracion" class="tabla">
            <thead>
                <tr>
                    <th>BASE DE DATOS</th>
                    <th>USAR</th>
                    <th>EDITABLE</th>
                </tr>
            </thead>
            <tbody>
                <?php foreach ($this->baseDeDatos as $_bd): ?>
                    <tr>
                        <td> <?php echo $_bd['BASE_DE_DATOS']; ?> </td>
                        <td> <input value="<?php echo $_bd['ID']; ?>" name="usar" class="usable" type="checkbox" <?php if ($_bd['USAR']): ?> checked <?php endif; ?>> </td>
                        <td> <input disabled type="checkbox" <?php if ($_bd['EDITABLE']) : ?> checked <?php endif; ?>> </td>
                    </tr>
                <?php endforeach; ?>
            </tbody>
        </table>
        <div class="center">
            <button type="submit" id="usar" class="boton">Usar</button>
        </div>
        <script>
            (function () {
                $('.usable').on('click', function (e) {
                    $('.' + e.currentTarget.className).attr('checked', false);
                    $(e.target).attr('checked', true);
                });
            }());
        </script>
    </form>
<?php endif; ?>
